package com.ruowei.modules.foodOrder.domain.enumeration;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ruowei.config.enumConfig.BaseEnum;

public enum OrderStatus implements BaseEnum {
    TO_BE_PAID("1", "待支付"),
    TO_BE_RECEIVED("2", "待接单"),
    MERCHANT_RECEIVED("3", "商家已接单"),
    MERCHANT_REFUSE_TO_RECEIVE("4", "商家拒绝接单"),
    COURIER_RECEIVED("5", "配送员已接单"),
    DELIVERED("6", "已送达"),
    CANCELLING("7", "订单取消中"),
    CANCELLED("8", "已取消"),
    REFUND_APPLYING("9", "退款申请中"),
    REFUND_AGREE("10", "退款同意"),
    REFUND_REFUSE("15", "退款拒绝"),
    REFUNDING("11", "退款中"),
    REFUNDED("12", "已退款"),
    REFUND_FAILED("13", "退款失败"),
    REFUND_CLOSED("14", "退款关闭");

    private final String code;
    private final String message;

    OrderStatus(String code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    @JsonValue
    public String getMessage() {
        return message;
    }

    @JsonCreator
    public static OrderStatus deserializer(String value) {
        for (OrderStatus item : values()) {
            if (value.equals(item.getCode())
                || value.equals(item.getMessage())) {
                return item;
            }
        }
        return null;
    }
}
